package servlet;

import java.io.IOException;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import dao.ArticleDAO;
import entity.Article;


/**
 * Servlet implementation class ChangeinformationServlet
 */
@WebServlet("/ChangeinformationServlet")
public class ChangeinformationServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
	private static ArticleDAO articledao = ArticleDAO.getInstance();   
    /**
     * @see HttpServlet#HttpServlet()
     */
    public ChangeinformationServlet() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		  SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");

		   int article_id =Integer.parseInt(request.getParameter("article_id"));
		   
		   String article_title = request.getParameter("article_title");
		   int user_id =Integer.parseInt(request.getParameter("user_id"));
		   int theme_id =Integer.parseInt(request.getParameter("theme_id"));
		   int article_istop =Integer.parseInt(request.getParameter("article_istop"));
		   int article_user_istop =Integer.parseInt(request.getParameter("article_user_istop"));
	
		   
		   Article article = articledao.get(article_id);
		   System.out.println("article_title:" + article_title);
		   article.setArticle_title(article_title);
		   System.out.println("user_id:" + user_id);
		   article.setUser_id(user_id);
		   System.out.println("theme_id:" + theme_id);
		   article.setTheme_id(theme_id);
		   System.out.println("article_istop:" + article_istop);
		   article.setArticle_istop(article_istop);
		   System.out.println("article_user_istop:" + article_user_istop);
		   article.setArticle_user_istop(article_user_istop);
		   articledao.update(article);
		    
		
		   request.getRequestDispatcher("ManageServlet").forward(request, response);
	}



}
